home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-05 / ipload.zip / BAPICHK.ASM < prev    next >
Assembly Source File  |  1991-03-01  |  5KB  |  163 lines

  1. ; BAPICHK.ASM
  2. ;
  3. ; 02-28-91  Michael McNeil
  4. ;<<<<<<<<<<
  5.  
  6. PAGE    92, 132
  7.  
  8. ;----------------------------------------------------------------------------
  9. ;----------------------------------------------------------------------------
  10. ;
  11. ;  Copyright 3Com Corporation, Santa Clara, California 1991
  12. ;
  13. ;----------------------------------------------------------------------------
  14. ;----------------------------------------------------------------------------
  15.  
  16. ;---------------------------------------------------------
  17. ; Check presence of BAPI
  18. ;
  19. ; by Michael McNeil
  20. ; 3Com Corporation
  21. ;---------------------------------------------------------
  22.  
  23. START_OFF    equ    0100h    ; origin offset for .COM files
  24.  
  25. ; ASCII characters
  26. ;
  27. NUL        equ    0    ; ASCII: NUL char
  28. LF        equ    0Ah    ; ASCII: LF char
  29. CR        equ    0Dh    ; ASCII: CR char
  30.  
  31. ; DOS function calls
  32. ;
  33. DOS_INT        equ    021h    ; interrupt to call DOS functions
  34. DOS_PRINT$    equ     09h    ; DOS function: print string up to '$'
  35. DOS_EXIT    equ    04Ch    ; DOS function: exit process with errorlevel
  36.  
  37. ; BAPI function calls
  38. ;
  39. BAPI_INT    equ    014h    ; interrupt to communicate with BAPI
  40. BAPI_CONNECT    equ    0A0h    ; function: connect to a port name
  41. BAPI_DISCON    equ    0A1h    ; function: disconnect
  42. BAPI_WRITEC    equ    0A2h    ; function: write a character
  43. BAPI_READC    equ    0A3h    ; function: read a character
  44. BAPI_WRITEB    equ    0A4h    ; function: write a block of characters
  45. BAPI_READB    equ    0A5h    ; function: read a block of characters
  46. BAPI_BREAK    equ    0A6h    ; function: send break
  47. BAPI_STATUS    equ    0A7h    ; function: read status
  48. BAPI_GET_X3    equ    0A8h    ; function: read X.3 parameters
  49. BAPI_SET_X3    equ    0A9h    ; function: set X.3 parameters
  50. BAPI_VER    equ    0AFh    ; function: interface version
  51. BAPI_EN_ECM    equ    0B0h    ; function: enable/disable ECM
  52. BAPI_ECM    equ    0B1h    ; function: Enter Command Mode
  53. BAPI_GET_ECM    equ    0B2h    ; function: get ECM watch state
  54. BAPI_MAGIC    equ    0AAAAh    ; magic number for version check
  55.  
  56. ERROR_BAPI    equ    0F0h    ; errorlevel to indicate error from bapi call
  57.  
  58. code    segment para public
  59. assume    cs: code, ds: code
  60.  
  61. ;%---------------------------------------------------------------------- begin
  62. ;
  63. ;    origin of program execution
  64. ;
  65. ;-%---------------------------------------------------------------------
  66.  
  67.     org    START_OFF        ; origin for .COM file
  68.  
  69. public    begin
  70. begin    proc    near
  71.       jmp    main            ; jump to main routine
  72. begin    endp
  73.  
  74. ;%---------------------------------------------------------------------- data
  75. ;
  76. ;    miscellaneous variables (permanent)
  77. ;
  78. ;-%---------------------------------------------------------------------
  79.  
  80. ;%------------------------------------------------------------------- bapichk
  81. ;
  82. ;    Do the work of the program
  83. ;
  84. ;    DS register is unchanged
  85. ;    other registers are not preserved
  86. ;
  87. ;-%------------------------------------------------------------------
  88.  
  89. public    bapichk
  90. bapichk    proc    near
  91.     clc                    ; start off with carry clear
  92.     mov    bx, BAPI_MAGIC
  93.     mov    ax, BAPI_VER * 0100h + 0h    ; BAPI version check function
  94.     int    BAPI_INT            ; call BAPI interrupt
  95.       jc    failure                ; if no error during call
  96.  
  97.     dec    al                ; decrement version no. to zero
  98. ;    clc                    ; show successful completion
  99. ;      jmp     return
  100.  
  101. ; return to caller
  102. ;
  103. return:
  104.       ret
  105.  
  106. ; error handler
  107. ;
  108. failure:
  109.     mov    dx, offset failed_msg        ; failed message
  110.     mov    ah, DOS_PRINT$            ; print string function
  111.     int    DOS_INT                ; call DOS function interrupt
  112.     stc                    ; indicate operation failed
  113.       jmp    short return
  114. bapichk    endp
  115.  
  116. ;%---------------------------------------------------------------------- main
  117. ;
  118. ;    main routine
  119. ;
  120. ;-%---------------------------------------------------------------------
  121.  
  122. public    main
  123. main    proc    near
  124. ;    cld                    ; clear default direction
  125.  
  126.     call    bapichk                ; call get bapi version subr.
  127.       jnc    no_error            ; if an error occurred
  128.  
  129.     mov    ax, DOS_EXIT * 0100h + ERROR_BAPI ; exit with errorlevel
  130.       int    DOS_INT                ; (doesn't return...)
  131.  
  132. ; if all has gone well...
  133. ;
  134. no_error:
  135.     mov    ah, DOS_EXIT            ; exit with no errorlevel
  136.       int    DOS_INT                ; (doesn't return...)
  137. main    endp
  138.  
  139. ;%---------------------------------------------------------------------- ddata
  140. ;
  141. ;    disposable data (discarded at termination)
  142. ;
  143. ;-%---------------------------------------------------------------------
  144.  
  145. public    failed_msg
  146. public    copy_right
  147. public    banner_msg
  148. public    ver_ident
  149. public    version_no
  150.  
  151. failed_msg    db    '*** BAPICHK: can''t check BAPI version'
  152.         db    CR, LF, '$', NUL
  153.  
  154. copy_right    db    'Copyright (C) 3Com Corporation 1991', NUL
  155.  
  156. banner_msg    db    '3Com Check BAPI Presence, Version '
  157. ver_ident    db    '%VER '
  158. version_no    db    '1.0', NUL, 'a', NUL
  159.  
  160. code    ends
  161. end    begin
  162.  
  163.